﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace Slippor.Douban.Radio.BaseForm.CustomControls
{
    public partial class DockPanel : UserControl
    {
        private String _dockText = String.Empty;

        public DockPanel()
        {
            InitializeComponent();
        }

        public String DockText
        {
            get { return _dockText; }
            set
            {
                _dockText = value;
                labelDock.Text = value;
            }
        }

        public Image IconImage
        {
            get { return pictureBoxIcon.Image; }
            set { pictureBoxIcon.Image = value; }
        }

        public void UpdateDockLayout()
        {
            switch (Dock)
            {
                case DockStyle.Bottom:
                    pictureBoxIcon.Dock = DockStyle.Left;
                    labelDock.Dock = DockStyle.Fill;
                    labelDock.Padding = new Padding(24, 1, 1, 1);
                    labelDock.TextAlign = ContentAlignment.MiddleCenter;
                    break;
                case DockStyle.Right:
                    labelDock.TextAlign = ContentAlignment.MiddleCenter;
                    labelDock.Dock = DockStyle.Fill;
                    labelDock.Padding = new Padding(1, 24, 1, 1);
                    pictureBoxIcon.Dock = DockStyle.Top;
                    break;
                case DockStyle.Left:
                    labelDock.TextAlign = ContentAlignment.MiddleCenter;
                    labelDock.Dock = DockStyle.Fill;
                    labelDock.Padding = new Padding(1, 24, 1, 1);
                    pictureBoxIcon.Dock = DockStyle.Top;
                    break;
            }
        }
    }
}